<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>

    <title>正在跳转</title>
    <script src="js/alert.js"></script>
</head>
<body style="text-align: center">
正在跳转
</body>
<script src="js/jquery.min.js"></script>
<script>
    (function ($) {
        $.getUrlParam1 = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null)
                return decodeURI(r[2]);
            return null;
        }
    })(jQuery);
</script>
<script>
    var appid;
    var redirect_url;
    var response_type;
    var scope;
    var state;
    var url;
    $(document).ready(function () {
        var token = $.getUrlParam1("token");

        $.ajax({
            "url":"/wechat/rus/",
            "data": "token=" +  token,
            "type": "GET",
            "dataType": "json",
            "success": function (json) {

                console.log(json.toString());
                appid = json.data.appid;

                response_type = json.data.responseType;
                scope = json.data.scope;
                state = $.getUrlParam1("token");
                redirect_url = json.data.redirectUrl+"/wechat/userdata/";

                url = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
                    "appid="+ appid +
                    "&redirect_uri=" + encodeURIComponent(redirect_url)+
                    "&response_type="+ response_type +
                    "&scope="+scope +
                    "&state="+state +
                    "#wechat_redirect";
                location.href = url;
            }
        })
    }

    );


</script>
</html>